<?php
	include '../ini.php';
	include '../includes/function.php';
	include '../libraries/xl_san_pham.php';
	include '../libraries/xl_loai_san_pham.php';
	include '../libraries/my_pager.php';
	
	$dt_xl_san_pham=new xl_san_pham;
	$dt_xl_loai_san_pham=new xl_loai_san_pham;
	$dt_phan_trang=new my_pager;
	if(empty($_GET['cate_id']))
	{
		$_SESSION['msg']='Lỗi! Dữ liệu không hợp lệ, vui lòng kiểm tra lại';
		$_SESSION['type_msg']='error';
		header('Location: .'.$_SERVER['HTTP_REFERER']);
		exit;
	}
	$ma_loai=$_GET['cate_id'];
	$loai_san_pham=$dt_xl_loai_san_pham->xem($ma_loai);
	if($loai_san_pham==NULL)
	{
		$_SESSION['msg']='Lỗi! Mã không hợp lệ, vui lòng kiểm tra lại';
		$_SESSION['type_msg']='error';
		header('Location: .'.$_SERVER['HTTP_REFERER']);
		exit;
	}	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en">
<head>
<?php include '../widgets/head.php'?>
</head>
<body>
<div id="art-page-background-glare">
  <div id="art-page-background-glare-image">
    <div id="art-main">
      <div class="art-sheet">
        <div class="art-sheet-tl"></div>
        <div class="art-sheet-tr"></div>
        <div class="art-sheet-bl"></div>
        <div class="art-sheet-br"></div>
        <div class="art-sheet-tc"></div>
        <div class="art-sheet-bc"></div>
        <div class="art-sheet-cl"></div>
        <div class="art-sheet-cr"></div>
        <div class="art-sheet-cc"></div>
        <div class="art-sheet-body">
          <?php include '../widgets/header.php'?>
          <?php include '../widgets/nav.php'; ?>
          <div class="art-content-layout">
            <div class="art-content-layout-row">
              <div class="art-layout-cell art-sidebar1">
                <?php sidebar('left');?>
                <div class="cleared"></div>
              </div>
              <div class="art-layout-cell art-content">
                <div class="art-post">
                  <div class="art-post-tl"></div>
                  <div class="art-post-tr"></div>
                  <div class="art-post-bl"></div>
                  <div class="art-post-br"></div>
                  <div class="art-post-tc"></div>
                  <div class="art-post-bc"></div>
                  <div class="art-post-cl"></div>
                  <div class="art-post-cr"></div>
                  <div class="art-post-cc"></div>
                  <div class="art-post-body">
                    <div class="art-post-inner art-article">
                    <?php thong_bao();?>
                      <h2 class="art-postheader"><?php
                      	$loai_san_pham_cha=$dt_xl_loai_san_pham->xem($loai_san_pham['ma_loai_cha']);
						echo $loai_san_pham_cha['ten'].' - '.$loai_san_pham['ten'];
					  ?></h2>
                      <div class="line"> </div>
                      <div class="art-postcontent">
                       <?php
					  	$vi_tri=$dt_phan_trang->vi_tri(USER_LIMIT);
					  	$ds_san_pham=$dt_xl_san_pham->danh_sach_theo_loai($ma_loai,$vi_tri,USER_LIMIT);
						foreach($ds_san_pham as $san_pham)
						{
					  ?>
                      <form method="post" action="../gio-hang/them.html">
                          	<input type="hidden" name="ma" value="<?php echo $san_pham['ma']?>"/>
                        <div class="san_pham"> <a class="ten" href="../chi-tiet-sach/<?php echo convert_vi_to_en($san_pham['ten'])?>-<?php echo $san_pham['ma']?>.html"><?php echo cat_chuoi($san_pham['ten'])?>
                        <img class="hinh" src="../upload/products/<?php echo $san_pham['hinh']?>" /><?php if($san_pham['san_pham_moi']==1) echo '<img id="new" src="../images/new.gif" />'?></a>
                          <div class="tool">
                            <div>Giá bán: <?php echo $san_pham['don_gia']?></div>
                            <input class="soluong" name="so_luong" type="text" value="1" />
                            <span class="art-button-wrapper"> <span class="art-button-l"> </span> <span class="art-button-r"> </span>
                            <input type="submit" name="mua_ngay" class="art-button" value="Mua ngay" />
                            </span> </div>
                        </div>
                        </form>
                         <?php
						}
					  ?>                      
                      </div>                      
                      <div class="cleared"></div>
                      <p class="phan-trang"><?php
					  	$tong_so_san_pham=$dt_xl_san_pham->so_luong_theo_ma($ma_loai);
                      	$tong_so_trang=$dt_phan_trang->tong_so_trang($tong_so_san_pham,USER_LIMIT);
						if($tong_so_san_pham > USER_LIMIT)
							echo $dt_phan_trang->xuat_phan_trang($_GET['page'],$tong_so_trang);
                      ?></p>
                    </div>
                    <div class="cleared"></div>
                  </div>
                </div>
                <div class="cleared"></div>
              </div>
              <div class="art-layout-cell art-sidebar2">
                <?php sidebar('right');?>
                <div class="cleared"></div>
              </div>
            </div>
          </div>
          <div class="cleared"></div>
          <?php include '../widgets/footer.php'?>
          <div class="cleared"></div>
        </div>
      </div>
      <div class="cleared"></div>
    </div>
  </div>
</div>
</body>
</html>
